package cn.tedu.myback.response;

import lombok.Data;

@Data
public class ResultVo {

    // 状态码 0成功 50001 用户不存在 -1系统异常
    private int code;

    // 状态信息：用户不存在
    private String msg;

    // 返回对象
    private Object data;

    // 手动设置返回vo
    public ResultVo(int code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    // 默认返回成功状态码，数据对象
    public ResultVo(Object data) {
        this.code = AppCode.SUCCESS.getCode();
        this.msg = AppCode.SUCCESS.getMsg();
        this.data = data;
    }

    // 返回指定状态码，数据对象
    public ResultVo(AppCode appCode, Object data) {
        this.code = appCode.getCode();
        this.msg = appCode.getMsg();
        this.data = data;
    }

    // 只返回状态码
    public ResultVo(AppCode appCode) {
        this.code = appCode.getCode();
        this.msg = appCode.getMsg();
        this.data = null;
    }
}
